<#include "/include/macros.ftl">
<@header>
    <style type="text/css">
        .toolbar {
            background-color: #f1f1f1;
            border: 1px solid #ccc;
        }
        .text {
            border: 1px solid #ccc;
            height: 200px;
        }
    </style>
</@header>
    <div class="clearfix"></div>

    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h2>wangEditor富文本编辑器用例
                        <small><a href="http://www.wangeditor.com/" target="_blank">http://www.wangeditor.com/</a></small>
                    </h2>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <br>
                    <form>
                        <div class="form-group row">
                            <label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">协议文本编辑器 </label>
                            <div class="col-md-8 col-sm-8 col-xs-12">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="type">类型 </label>
                                <select id="type" class="form-control">
                                    <option value="test">测试</option>
                                    <option value="MerchantCooperation">商家合作协议</option>
                                    <option value="ApplyDesign">设计师申请协议</option>
                                    <option value="cooperationDescription">商家合作步骤及说明</option>
                                </select>
                                <br>
                                <div id="editor">

                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="control-label col-md-1 col-sm-1 col-xs-12"></label>
                                    <div class="col-md-10 col-sm-10 col-xs-12">
                                        <button type="submit" class="btn btn-success to-choose-info" id="save"><i class="fa fa-pencil"> 确定</i></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<@footer>
    <script type="text/javascript">
        let E = window.wangEditor;
        // oneblog定制版的wangEditor
        zhyd.wangEditor.init({
            container: "#editor",
            textareaName: "content",
            uploadUrl: "/api/uploadFile",
            uploadFileName: "file",
            uploadType: "goods",
            customCss: {
                "overflow-y": "scroll",
                "height": "500px",
                "max-height": "600px"
            }
        });


        $("#save").click(function(){
            let content = editor.txt.html();
            let type = $("#type").val();
            // Ajax提交数据
            $.ajax({
                url: "/protocol/saveProtocol",
                type: "post",
                data: {"content": content,"type":type},
                dataType: "json",
                success: function (data) {
                    if (data) {
                        $(location).attr('href', '/protocol/getProtocol?type=' + type);
                    }
                },
            });
        })

    </script>
</@footer>